// JavaScript Document
function drawBackground(tex)
{
	c_px = -camera.x; //camera pos X
	c_py = -camera.y; //camera pos Y
	g_w = canvas.width; //window width
	g_h = canvas.height; //window height
	sb1_width = 512; //back width
	sb1_height = 512; //back height
	//right
	i = 0;
	ctx.drawImage(images["floor_bg"],-256,-256);
	
	/*
	while ((c_px - (c_px % sb1_width) + (i * sb1_width)) < g_w)
    {
    	
    	ctx.save();
		ctx.setTransform(1, 0, 0, 1, 0, 0);
		ctx.fillText(c_px + ":" + c_px % sb1_width + ":" + (i * sb1_width), 10, 40);
  		ctx.fillText(c_px - (c_px % sb1_width) + (i * sb1_width), 10, 50 * i);
  		ctx.restore();
    	
    	//down
		j = 0;
		while ((c_py - (c_py % sb1_height) + (j * sb1_height)) < g_h)
		{
  			
			ctx.drawImage(images["floor_bg"],
				c_px - (c_px % sb1_width) + (i * sb1_width),
				c_py - (c_py % sb1_height) + (j * sb1_height));
			j++;
		}
		//up
		
		j = -1;
		while ((c_py - c_py % sb1_height + (j + 1) * sb1_height) > 0)
		{ 
			ctx.drawImage(images["floor_bg"],
				c_px - c_px % sb1_width + i * sb1_width,
				c_py - c_py % sb1_height + j * sb1_height);
			j--;
                    
		}
		
		i++;
		
	}
	//left
	
	i = -1;
	while ((c_px - c_px % sb1_width + (i + 1) * sb1_width) > 0)
	{
		//down
		j = 0;
		while ((c_py - c_py % sb1_height + j * sb1_height) < g_h)
		{
			ctx.drawImage(images["floor_bg"],
				c_px - c_px % sb1_width + i * sb1_width,
				c_py - c_py % sb1_height + j * sb1_height);
                    j++;
		}*/
		//up
		/*
		j = -1;
		while ((c_py - c_py % sb1_height + (j + 1) * sb1_height) > 0)
		{

            ctx.drawImage(images["floor_bg"],
				c_px - c_px % sb1_width + i * sb1_width,
				c_py - c_py % sb1_height + j * sb1_height);
        	j--;
		}
		i--;
	}*/
}